<?php

/**
 * Invoice filter form.
 *
 * @package    billingSystem
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class InvoiceFormFilter extends BaseInvoiceFormFilter
{
        function configure()
        {
                $this->widgetSchema['partner']=new sfWidgetFormInputText(array('label'=>'partner name'));
                $this->validatorSchema['partner'] = new sfValidatorPass(array ('required' => false));
                $this->widgetSchema['product']=new sfWidgetFormInputText(array('label'=>'product name'));
                $this->validatorSchema['product'] = new sfValidatorPass(array ('required' => false));
        }
        function  getFields() {
                $fields=parent::getFields();
                $fields['partner']='Text';
                $fields['product']='Text';
                return $fields;
        }
        //used for filter by Partner Name
        //add{virtual_column_name}ColumnQuery($q , $field, $value) =>constant
        function addPartnerColumnQuery($q , $field, $value)
        {
                $name=explode(" ", $value);
                $fname=$name[0];
                $lname=$name[1];
                return Doctrine_Core::getTable('Invoice')->searchByPartnerName($q,$fname,$lname);
        }
        function addProductColumnQuery($q , $field, $value)
        {
                return Doctrine_Core::getTable('Invoice')->searchByProductName($q,$value);
        }
}
